package GUI;

import java.awt.Graphics;

import java.awt.Image;
import java.util.ArrayList;

import javax.swing.JFrame;

import com.sun.javafx.geom.Point2D;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Result extends JFrame{
	
	
	JCheckBox chbresult1;
	JCheckBox chbresult2;
	JCheckBox chbresult3;
	JCheckBox chbresult4;
	JCheckBox chbresult5;
	JPanel panel;
	ArrayList<Integer> xlist = new ArrayList<Integer>();
	ArrayList<Integer> ylist = new ArrayList<Integer>();
	
	public ArrayList<Integer> getXlist() {
		return xlist;
	}
	public ArrayList<Integer> getYlist() {
		return ylist;
	}
	public void setXlist(ArrayList<Integer> getxlist){
		this.xlist=getxlist;
	}
	public void setYlist(ArrayList<Integer> getylist){
		this.ylist=getylist;	
	}
	public Result() {
		 
		getContentPane().setLayout(null);
		setBounds(0,0,540,360);
		panel = new JPanel(){
	         public void paintComponent(Graphics g){
	             Image image = new ImageIcon("result.png").getImage();
	             g.drawImage(image, 0, 0, this);
	          }      
	       };
		panel.setOpaque(false);
		panel.setBounds(0, 0, 524, 321);
		getContentPane().add(panel);
		panel.setLayout(null);
		
		
		chbresult1 = new JCheckBox("");
		chbresult1.setOpaque(false);
		chbresult1.setBounds(171, 50, 220, 40);
		chbresult1.setText("test");
		this.panel.add(chbresult1);
		chbresult2 = new JCheckBox("");
		chbresult2.setOpaque(false);
		chbresult2.setBounds(171, 90, 220, 40);
		this.panel.add(chbresult2);
		chbresult3 = new JCheckBox("");
		chbresult3.setOpaque(false);
		chbresult3.setBounds(171, 130, 220, 40);
		this.panel.add(chbresult3);
		chbresult4 = new JCheckBox("");
		chbresult4.setOpaque(false);
		chbresult4.setBounds(171, 170, 220, 40);
		this.panel.add(chbresult4);
		chbresult5 = new JCheckBox("");
		chbresult5.setOpaque(false);
		chbresult5.setBounds(171, 210, 220, 40);
		this.panel.add(chbresult5);
		
		JButton btnNewButton = new JButton("New button"){
	         public void paintComponent(Graphics g){
	             Image image = new ImageIcon("iconadd3.png").getImage();
	             g.drawImage(image, 0, 0, this);
	          }      
	       };
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnNewButton.setBorder(null);
		btnNewButton.setBounds(171, 250, 220, 40);
		panel.add(btnNewButton);
		
		
	}

	
	
	public void apprearDay(){
		//if enable time is 0
		if(xlist.size()==0){
			System.out.println("Nothing");
		}//if enable time is 1
		if(xlist.size()==1){
			chbresult1.setText("result 1:  "+(xlist.get(0))+1+"day, time:  "+(ylist.get(0))+9);
			repaint();
		}//if enable time is 2
		else if(xlist.size()==2){
			chbresult1.setText("result 1:  "+(xlist.get(0))+1+"day, time:  "+(ylist.get(0))+9);
			chbresult2.setText("result 2:  "+(xlist.get(1))+1+"day, time:  "+(ylist.get(1))+9);
			repaint();
		}//if enable time is 3
		else if(xlist.size()==3){
			chbresult1.setText("result 1:  "+(xlist.get(0))+1+"day, time:  "+(ylist.get(0))+9);
			chbresult2.setText("result 2:  "+(xlist.get(1))+1+"day, time:  "+(ylist.get(1))+9);
			chbresult3.setText("result 3:  "+(xlist.get(2))+1+"day, time:  "+(ylist.get(2))+9);
			repaint();
		}//if enable time is 4
		else if(xlist.size()==4){
			chbresult1.setText("result 1:  "+(xlist.get(0))+1+"day, time:  "+(ylist.get(0))+9);
			chbresult2.setText("result 2:  "+(xlist.get(1))+1+"day, time:  "+(ylist.get(1))+9);
			chbresult3.setText("result 3:  "+(xlist.get(2))+1+"day, time:  "+(ylist.get(2))+9);
			chbresult4.setText("result 4:  "+(xlist.get(3))+1+"day, time:  "+(ylist.get(3))+9);
			repaint();
		}//if enable time is over 5
		else if(xlist.size()>=5){
			chbresult1.setText("result 1:  "+(xlist.get(0))+1+"day, time:  "+(ylist.get(0))+9);
			chbresult2.setText("result 2:  "+(xlist.get(1))+1+"day, time:  "+(ylist.get(1))+9);
			chbresult3.setText("result 3:  "+(xlist.get(2))+1+"day, time:  "+(ylist.get(2))+9);
			chbresult4.setText("result 4:  "+(xlist.get(3))+1+"day, time:  "+(ylist.get(3))+9);
			chbresult5.setText("result 5:  "+(xlist.get(4))+1+"day, time:  "+(ylist.get(4))+9);
			repaint();
		}
		
	}
}
